package me.sel.springboot.starter.config;

import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import me.sel.springboot.starter.service.TestService;

public class LoginWebAppConfigurer extends WebMvcConfigurerAdapter implements EnvironmentAware{

	private Environment environment;

//	public FilterRegistrationBean filterRegistration() {
//		FilterRegistrationBean registration = new FilterRegistrationBean();
//		registration.setDispatcherTypes(DispatcherType.REQUEST, new DispatcherType[0]);
//		registration.setFilter(new SessionFilter());
//		return registration;
//	}
//
//	public FilterRegistrationBean webUserParseFilterRegistration() {
//		FilterRegistrationBean registrationBean = new FilterRegistrationBean();
//		DelegatingFilterProxy filterProxy = new DelegatingFilterProxy();
//		registrationBean.setFilter(filterProxy);
//		Map<String, String> m = new HashMap<>();
//		m.put("targetBeanName", "cookieWebUserParseFilter");
//		m.put("targetFilterLifecycle", "true");
//		registrationBean.setInitParameters(m);
//		return registrationBean;
//	}
//
//	public Filter cookieWebUserParseFilter() {
//		return new CookieWebUserParseFilter();
//	}
//
//	public LoginExceptionHandler globalBindExceptionHandler() {
//		return new LoginExceptionHandler();
//	}
//
//	public CookieUserAccessInterceptor userAccessInterceptor() {
//		return new CookieUserAccessInterceptor();
//	}
//
//	public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
//		super.addArgumentResolvers(argumentResolvers);
//		argumentResolvers.add(new WebUserArgumentResolver());
//	}
//
//	public LoginExceptionResolver loginExceptionResolver() {
//		return new LoginExceptionResolver();
//	}
//
//	public LoginCookieSupporter loginCookieSupporterDev() {
//		return new LoginCookieSupporter("dev", environment);
//	}
//
//	public LoginCookieSupporter loginCookieSupporterTest() {
//		return new LoginCookieSupporter("test", environment);
//	}
//
//	public LoginCookieSupporter loginCookieSupporterProd() {
//		return new LoginCookieSupporter("prod", environment);
//	}
	
	@Bean
	public TestService testService() {
		return new TestService();
	}

	@Override
	public void setEnvironment(Environment environment) {
		System.out.println(environment);
		this.environment = environment;
		
	}

}
